const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
moment.locale('zh-cn'); 

const BorrowSchema = new Schema({
  bookId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Book',
      required: true
  },
  userId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'User',
      required: true
  },

  createdAt: {
      type: Date,
      required: true,
      createdAt: moment().format('YYYY-MM-DD HH:mm:ss'),
    },
    updatedAt: {
      type: Date,
      required: true,
      updatedAt: moment().format('YYYY-MM-DD HH:mm:ss')
  },
}, {
  timestamps: true
});

const Borrow = mongoose.model('Borrow', BorrowSchema);
module.exports = Borrow;